import axiosReq from './axiosReq.js'
let baseURL = window.Apiurl
const setting = {
    globalUrl: {
        base: baseURL,
        server: baseURL,
        uploadserver: "/zh8848/upload",
        upload: baseURL+"/upload",
        fileurl: baseURL
    },
    globalData:{
        ranks: [
            { id: 0, name: '干事' },
            { id: 1, name: '副处长' },
            { id: 2, name: '处长' },
            { id: 3, name: '副局长' },
            { id: 4, name: '局长' }
        ],
        flags: [
            { id: '1', name: '编辑' },
            { id: '2', name: '上传' },
            { id: '3', name: '删除' },
            { id: '4', name: '下载' },
            { id: '5', name: '分享' }
        ],
        categorys: [
            { id: '0', name: '历史文件' },
            { id: '1', name: '普通文件' },
            { id: '3', name: '舆情事件' },  
        ],
        fileStates: [
            { id: 0, name: '呈签中' },
            { id: 1, name: '呈签完毕' },
            { id: 2, name: '督办中' },
            { id: 3, name: '完成' }, 
        ],
        opiniontypes: [
            { id: 1, name: '无端抹黑' },
            { id: 2, name: '涉诉涉访' },
            { id: 3, name: '涉医涉疫' },
            { id: 4, name: '婚恋' },
            { id: 5, name: '军车违章' },
            { id: 6, name: '暴露军人身份' },
            { id: 7, name: '其他' },
        ],
        keyzhs: {
            "boutique": "是否精品文件",
            "state": "办理进度",
            "code": "文件编号",
            "name": "文件名称",
            "introduction": "舆情简介",
            "synopsis": "简介",
            "keyword": "关键词",
            "company_id": "承办单位",
            "supervise": "督办情况",
            "imgs": "图片",
            "files": "文件",
            "instructions": "首长批示",
            "opinion_type" :"舆情类型",
        },
        op_keyzhs: {
            "boutique": "是否精品文件",
            "state": "办理进度",
            "code": "编号",
            "name": "事件名称",
            "introduction": "舆情简介",
            "synopsis": "处置情况",
            "keyword": "关键词",
            "company_id": "涉及单位",
            "supervise": "督办情况",
            "imgs": "图片",
            "files": "文件",
            "instructions": "首长批示",
            "opinion_type" :"舆情类型",
        },
        provinces: [
            {value: 0, "id": 1, "name": "北京市", "abbreviation": "京"},  
            {value: 0, "id": 2, "name": "天津市", "abbreviation": "津"},  
            {value: 0, "id": 3, "name": "上海市", "abbreviation": "沪"},  
            {value: 0, "id": 4, "name": "重庆市", "abbreviation": "渝"},  
            {value: 0, "id": 5, "name": "河北省", "abbreviation": "冀"},  
            {value: 0, "id": 6, "name": "山西省", "abbreviation": "晋"},  
            {value: 0, "id": 7, "name": "辽宁省", "abbreviation": "辽"},  
            {value: 0, "id": 8, "name": "吉林省", "abbreviation": "吉"},  
            {value: 0, "id": 9, "name": "黑龙江省", "abbreviation": "黑"},  
            {value: 0, "id": 10, "name": "江苏省", "abbreviation": "苏"},  
            {value: 0, "id": 11, "name": "浙江省", "abbreviation": "浙"},  
            {value: 0, "id": 12, "name": "安徽省", "abbreviation": "皖"},  
            {value: 0, "id": 13, "name": "福建省", "abbreviation": "闽"},  
            {value: 0, "id": 14, "name": "江西省", "abbreviation": "赣"},  
            {value: 0, "id": 15, "name": "山东省", "abbreviation": "鲁"},  
            {value: 0, "id": 16, "name": "河南省", "abbreviation": "豫"},  
            {value: 0, "id": 17, "name": "湖北省", "abbreviation": "鄂"},  
            {value: 0, "id": 18, "name": "湖南省", "abbreviation": "湘"},  
            {value: 0, "id": 19, "name": "广东省", "abbreviation": "粤"},  
            {value: 0, "id": 20, "name": "海南省", "abbreviation": "琼"},  
            {value: 0, "id": 21, "name": "四川省", "abbreviation": "川"},  
            {value: 0, "id": 22, "name": "贵州省", "abbreviation": "黔"},  
            {value: 0, "id": 23, "name": "云南省", "abbreviation": "滇"},  
            {value: 0, "id": 24, "name": "陕西省", "abbreviation": "陕"},  
            {value: 0, "id": 25, "name": "甘肃省", "abbreviation": "甘"},  
            {value: 0, "id": 26, "name": "青海省", "abbreviation": "青"},  
            {value: 0, "id": 27, "name": "台湾省", "abbreviation": "台"},  
            {value: 0, "id": 28, "name": "内蒙古自治区", "abbreviation": "内蒙古"},  
            {value: 0, "id": 29, "name": "广西壮族自治区", "abbreviation": "桂"},  
            {value: 0, "id": 30, "name": "西藏自治区", "abbreviation": "藏"},  
            {value: 0, "id": 31, "name": "宁夏回族自治区", "abbreviation": "宁"},  
            {value: 0, "id": 32, "name": "新疆维吾尔自治区", "abbreviation": "新"},  
            {value: 0, "id": 33, "name": "香港特别行政区", "abbreviation": "港"},  
            {value: 0, "id": 34, "name": "澳门特别行政区", "abbreviation": "澳"},  
            {value: 0, "id": 35, "name": "南海诸岛", "abbreviation": "南海诸岛"}
        ],
        authority: [
            {
                "label": "组织架构",
                "icon": "4",
                "component": "",
                "powers": [],
                "show": true,
                "sub": [
                    {
                        "label": "人员管理",
                        "component": "user",
                        "childs": ['/user','/userEdit'],
                        "powers": [],
                        "show": true,
                        "sub": []
                    },
                    {
                        "label": "部门管理",
                        "component": "department",
                        "childs": ['/department','/departEdit'],
                        "powers": [],
                        "show": true,
                        "sub": []
                    },
                    {
                        "label": "单位管理",
                        "component": "company",
                        "childs": ['/company','/companyEdit'],
                        "powers": [],
                        "show": true,
                        "sub": []
                    },
                ]
            },{
                "label": "编号规则",
                "icon": "5",
                "component": "",
                "powers": [],
                "show": true,
                "sub": [
                    {
                        "label": "编号规则",
                        "component": "ref",
                        "childs": ['/ref','/refEdit'],
                        "powers": [],
                        "show": true,
                        "sub": []
                    }
                ]
            },
            // {
            //     "label": "配置管理",
            //     "icon": "5",
            //     "component": "",
            //     "powers": [],
            //     "show": true,
            //     "sub": [
            //         {
            //             "label": "配置管理",
            //             "component": "configEdit",
            //             "childs": ['/configEdit'],
            //             "powers": [],
            //             "show": true,
            //             "sub": []
            //         }
            //     ]
            // },
            {
                "label": "文件管理",
                "icon": "3",
                "component": "",
                "powers": [],
                "show": true,
                "sub": [
                    {
                        "label": "待办文件",
                        "component": "schfile",
                        "childs": ['/schfile','/schfileEdit'],
                        "powers": [],
                        "show": true,
                        "sub": []
                    },{
                        "label": "完成文件",
                        "component": "comfile",
                        "childs": ['/comfile','/comfileEdit'],
                        "powers": [],
                        "show": true,
                        "sub": []
                    },{
                        "label": "精品文件",
                        "component": "toufile",
                        "childs": ['/toufile','/toufileEdit'],
                        "powers": [],
                        "show": true,
                        "sub": []
                    },{
                        "label": "历史文件",
                        "component": "hisfile",
                        "childs": ['/hisfile','/hisfileEdit'],
                        "powers": [],
                        "show": true,
                        "sub": []
                    }
                ]
            },{
                "label": "舆情事件",
                "icon": "7",
                "component": "",
                "powers": [],
                "show": true,
                "childs": [],
                "sub": [
                    {
                        "label": "舆情事件",
                        "component": "opinionfile",
                        "childs": ['/opinionfile','/opinionfileEdit'],
                        "powers": [],
                        "show": true,
                        "sub": []
                    }
                ]
            }
        ],
        sexAry: [
            { status: 0, text: "未知" }, 
            { status: 1, text: "男" }, 
            { status: 2, text: "女" } 
        ],
        stateTypeAry: [ 
            { status: 0, text: "停用" }, 
            { status: 1, text: "正常" } 
        ],
        userVerifyAry: [ 
            { status:0, text: "不是" },
            { status:1, text: "申请中" },
            { status:2, text: "已通过" },
            { status:3, text: "已拒绝" },
        ],
        configAry: [
            { status:0, text:"职业" },
            { status:1, text:"爱好" },
            { status:2, text:"身高" },
            { status:3, text:"乳量" },
            { status:4, text:"人种" },
            { status:5, text:"宗教" },
            { status:6, text:"区域" },
            { status:7, text:"上班可看~" },
            { status:8, text:"上班别看><" },
            { status:9, text:"创作类型" },
            { status:10, text:"性别" },
            { status:11, text:"服装" },
            { status:12, text:"尺度" },
            { status:13, text:"部位" },
            { status:14, text:"场地" },
        ],
        orderTypeAry:[
            { status:0, text:"照片订单" },
            { status:1, text:"视频订单" },
        ],
        payedAry: [
            { status:0, text:"未支付" },
            { status:1, text:"已支付" },
        ],
        confirmAry: [
            { status:0, text:"待确认" },
            { status:1, text:"已确认" },
            { status:2, text:"拒绝" },
        ],
        orderStateAry: [
            { status:0, text:"待接单" },
            { status:1, text:"已派单" },
            { status:2, text:"进行中" },
            { status:3, text:"已接单" },
            { status:4, text:"已完成" },
            { status:5, text:"已拒绝" },
            { status:6, text:"已取消" },
            { status:100, text:"订单池" },
        ],
        cashoutAry:[
            { status:0, text:"申请中" },
            { status:1, text:"已同意" },
            { status:2, text:"已拒绝" },
        ]
    },
    getcompanys(){
        return new Promise((resovle,rej)=>{
            axiosReq({
                url: 'root/root/company',
                data: {},
                bfLoading: true
            }).then(res => {
                let list = res.msg.list||[]
                list.map(e=>e.id=e.company_id)
                resovle(list||[])
            }).catch(() => {resovle([])})
        })
    },
    getdepts(){
        return new Promise((resovle,rej)=>{
            axiosReq({
                url: 'root/root/dept',
                data: {},
                bfLoading: true
            }).then(res => {
                let list = res.msg.list||[]
                list.map(e=>e.id=e.dept_id)
                resovle(list||[])
            }).catch(() => {resovle([])})
        })
    },
    getrefs(){
        return new Promise((resovle,rej)=>{
            axiosReq({
                url: 'root/root/ref',
                data: {},
                bfLoading: true
            }).then(res => {
                resovle(res.msg.list||{})
            }).catch(() => {resovle([])})
        })
    },
    getusers(dept_id){
        return new Promise((resovle,rej)=>{
            axiosReq({
                url: 'root/root/user',
                data: {dept_id:dept_id},
                bfLoading: true
            }).then(res => {
                let list = res.msg.list||[]
                list.map(e=>e.id=e.userid)
                resovle(list||[])
            }).catch(() => {resovle([])})
        })
    },
    geteditmsg(proxy,local,data,keyzhs='keyzhs'){
        return new Promise(async(resolve, reject) => {
            let arr = []
            let arr_ = []
            for (const key in data) {
                if(!(['file_id'].includes(key))){
                    if(JSON.stringify(data[key])!==JSON.stringify(local[key])){
                        let old = ''
                        let news = ''
                        if(key=='company_id'){
                            old = local.company_name
                            news = await this.getcomname(data.company_id)
                        }else if(['imgs','files'].includes(key)){
                            old = local[key].split(',').map(e=>`${proxy.$setting.globalUrl.fileurl}/files/${e}`)
                            news = data[key].split(',').map(e=>`${proxy.$setting.globalUrl.fileurl}/files/${e}`)
                        }else if(key=='instructions'){
                            old = local[key].map(e=>`批示时间:${e.intime},批示内容:${e.msg}`).join(',')
                            news = data[key].map(e=>`批示时间:${e.intime},批示内容:${e.msg}`).join(',')
                        }else if(key=='boutique'){
                            old = local[key]==1?'精品文件':'非精品文件'
                            news = data[key]==1?'精品文件':'非精品文件'
                        }else if(key=='state'){
                            old = local[key]?(proxy.$setting.globalData.fileStates.find(e=>e.id==local[key])).name:''
                            news = data[key]?(proxy.$setting.globalData.fileStates.find(e=>e.id==data[key])).name:''
                        }else if(key=='opinion_type'){
                            old = this.globalData.opiniontypes[local[key]-1].name
                            news = this.globalData.opiniontypes[data[key]-1].name
                        }else{
                            old = local[key]
                            news = data[key]
                        }
                        arr.push(`${arr.length+1}.${proxy.$setting.globalData[keyzhs][key]}：修改前为'${old}'，修改后为'${news}'`)
                        arr_.push(proxy.$setting.globalData[keyzhs][key])
                    }
                }
            }
            resolve(arr.length?{
                msg: `${proxy.$useStore().getUser.name}修改记录，${arr.join(';')}`,
                msg_simple: `${proxy.$useStore().getUser.name}修改了${arr_.join(',')}`
            }:{msg_simple:'',msg:''})
        })
    },
    async getcomname(ids){
        return new Promise(async(resolve, reject) => {
            if(ids.length>1){
                let arr = await this.getcompanys()
                let o = arr.find(e=>ids[0]==e.province)
                if(o){
                    resolve(o.name||'')
                }
            }else{resolve('')} 
        })
    }
}
export default setting